angular.module("me",[])
.config(["$stateProvider",function($stateProvider){
	$stateProvider.state("/me",{
		url:"/me",
		templateUrl:"html/me/me.html",
		css:"html/me/me.css",
		controller:"meController"
	})
}]).controller("meController",function($scope){
	// 初始化bmob
	Bmob.initialize("718d210c8206999d9a100c4fdbe68e4e","aff8e91a770dde6a00d31002b057645a");
	// 创建一个数据表
	var Login = Bmob.Object.extend("Login");
	
	//注册
	var zc = document.getElementById("zc").onclick = function(){
		var names = document.getElementById("names").value;
		var password = document.getElementById("password").value;
		var login = new Login();
	    login.set('names',names);
	    login.set('password',password);
	    if(names != 'admin'){
	    	login.save(null,{
	    		success:function(object){
		    		alert('注册成功');
	    		}
	    	})
	    }else{
    		alert('用户名已存在')
    	}
	}
	//登录
	var sur = document.getElementById("sur").onclick = function(){
		var names = document.getElementById("names").value;
		var password = document.getElementById("password").value;
		var query = new Bmob.Query(Login);
	    query.get("e9c9b40740", {
	      success: function(object) {
	        alert("登录成功");
	      },
	      error: function(error) {
	        alert("登录失败");
	      }
	    });
	}
})